﻿angular.module("ng-unvs-utils", [])
.service("$utils$text", function () {
    if (!window.top.ngW8.$Funcs) {
        window.top.ngW8.$Funcs = {};
    }
    return {
        $clean: function (strBegin, strEnd, strContent) {
            var bLink = strContent.indexOf(strBegin);
            if (bLink > -1) {
                var eLink = strContent.indexOf(strEnd, bLink);
                strContent = strContent.substring(0, bLink) + strContent.substring(eLink + strEnd.length + 1, strContent.length);
            }
            return strContent;
        },
        $extract: function (strBegin, strEnd, strContent) {
            var i = strContent.indexOf(strBegin);
            if (i > -1) {
                i = i + strBegin.length;
                var j = strContent.indexOf(strEnd, i);
                var ret = strContent.substring(i, j);
                return ret;
            }
            return "";
        },
        $replace: function (strFind, strReplace, strContent) {
            while (strContent.indexOf(strFind) > -1) {
                strContent = strContent.replace(strFind, strReplace);
            }
            return strContent;
        }
    }
})

